#include "Sample.h"

bool Sample::PreCoreRender()
{
	m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 );

	if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
	{
		return true;
	}	
	return false;	
}

bool Sample::Init()
{
	this->m_Camera.SetView( D3DXVECTOR3(10.0f, 3.0f, 3.0f),
							D3DXVECTOR3(0.0f, 0.0f, 0.0f) );
	return true;

}
bool Sample::Frame()
{
	static float fAngle = 0.0f;
	fAngle += this->m_Time.m_fSecPerFrame;
	this->m_Camera.SetView( D3DXVECTOR3(cosf(fAngle), 3.0f, sinf(fAngle)),
							D3DXVECTOR3(0.0f, 0.0f, 0.0f) );

	return true;
}

bool Sample::Render()
{
	m_Debug.DrawLine( m_pd3dDevice, D3DXVECTOR3(-1.0f, -1.0f, 0.0f ),
					  D3DXVECTOR3( 0.0f, 1.0f,  0.0f ),
					  0xffff00 );
	m_Debug.DrawLine( m_pd3dDevice, D3DXVECTOR3( 0.0f, 1.0f, 0.0f ),
					  D3DXVECTOR3( 1.0f, -1.0f,  0.0f ),
					  0xffff00 );
	m_Debug.DrawLine( m_pd3dDevice, D3DXVECTOR3(1.0f, -1.0f, 0.0f ),
					  D3DXVECTOR3( -1.0f, -1.0f,  0.0f ),
					  0xffff00 );
	return true;
}

Sample::Sample(void)
{
	
}

Sample::~Sample(void)
{
}

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
	Sample gSample;
	if( !gSample.CreateWin(hInst,_T("SampleDebug")))
	{
		return 0;
	}
	if( !gSample.CreateDevice())
	{
		return 0;
	}
	gSample.Run();
	return 1;
}